<template>
	<section class="jumbotron">
		<h3 class="jumbotron-heading">Search Github Users</h3>
		<div>
			<input v-model="keyword" type="text" placeholder="enter the name you search"/>&nbsp;
			<button @click="sendAjax">Search</button>
		</div>
	</section>
</template>

<script>
	export default {
		name: 'Search',
		data() {
			return {
				keyword:''
			}
		},
		methods: {
			sendAjax(){
				this.$http.get(`https://api.github.com/search/users?q=${this.keyword}`).then(
					response => {
						console.log('请求成功了',response.data.items)
						this.$bus.$emit('save-user-list',response.data.items)
					},
					error => {
						alert(error.message)
					}
				)
			}
		},
	}
</script>
